package com.zhuqi.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.zhuqi.domain.ChatUser;
import com.zhuqi.mapper.ChatUserMapper;
import com.zhuqi.service.ChatUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class ChatUserServiceImpl implements ChatUserService {

	@Resource
	private ChatUserMapper chatUserMapper;

	@Override
	public int deleteByPrimaryKey(Integer id) {
		return chatUserMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(ChatUser record) {
		return chatUserMapper.insert(record);
	}

	@Override
	public int insertSelective(ChatUser record) {
		return chatUserMapper.insertSelective(record);
	}

	@Override
	public ChatUser selectByPrimaryKey(Integer id) {
		return chatUserMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(ChatUser record) {
		return chatUserMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(ChatUser record) {
		return chatUserMapper.updateByPrimaryKey(record);
	}


	/**
	 * 登陆
	 * @param username 用户名
	 * @param password 密码
	 * @return 登录成功返回 true，否则返回 false
	 */
	@Override
	public boolean login(String username, String password) {
		ChatUser chatUser = chatUserMapper.selectByUserName(username);
		if (ObjectUtil.isNotEmpty(chatUser)) {
			if (chatUser.getPassword().equals(password)) {
				return Boolean.TRUE;
			}
		}
		return Boolean.FALSE;
	}


}
